package main

import (
	"fmt"
	"unicode/utf8"
)

func main() {

	array1 := [5]string{"a", "b", "c", "d", "e"}
	fmt.Println(array1[2])

	array2 := [...]string{"a", "b", "c", "d", "e"}
	fmt.Println(array2)

	array3 := [5]int{1: 1, 3: 3}
	fmt.Println(array3)
	for i := 0; i < len(array3); i++ {
		fmt.Println("i is ", i, ",value is ", array3[i])
	}

	for i, v := range array3 {
		fmt.Println("i is ", i, ",value is ", v)
	}

	array := [5]string{"a", "b", "c", "d", "e"}
	slice := array[2:5]
	fmt.Println(slice)
	slice[0] = "x"
	fmt.Println(array)

	slice1 := make([]string, 4, 8)
	slice1[0] = "a"
	slice1 = append(slice1, "b")
	fmt.Println(slice1)

	nameAgeMap := make(map[string]int)
	nameAgeMap["alice"] = 20
	nameAgeMap["bob"] = 30
	fmt.Println(nameAgeMap)
	age, ok := nameAgeMap["alice"]
	if ok {
		fmt.Println(age)
	}
	delete(nameAgeMap, "alice")
	for v, k := range nameAgeMap {
		fmt.Println("v is ", v, ",k is ", k)
	}
	fmt.Println(len(nameAgeMap))

	s := "Hello哈哈哈哈"
	bs := []byte(s)

	fmt.Println(bs)
	fmt.Println(s[0], s[1], s[15])
	fmt.Println(len(s))
	fmt.Println(utf8.RuneCountInString(s))
	for i, r := range s {
		fmt.Println(i, r)
	}
}
